package com.example.demo.commom;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.Data;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User:龙宝
 * Date:2023-11-18
 * Time:17:55
 */
@Data
public class JsonResult {
    private Integer type;//0表示给所有用户发送的消息，表示前端要填充到消息框中;1表示用户的号数填充
    private String message;//消息体

    private static ObjectMapper objectMapper = new ObjectMapper();
    public static String JsonMessage(Integer type,String message) throws JsonProcessingException {
        JsonResult result = new JsonResult();
        result.setType(type);
        result.setMessage(message);
        return objectMapper.writeValueAsString(result);
    }
}
